<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/headMain.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<title>订单详情</title>
  </head>
  		<script type="text/javascript">
		$(function(){
				$("#_detailGrid").jqGrid({
				   	url: "${base}/order_getDetailList/${orderId }",
					datatype: "json",
				   	colNames:['ID','食物名称','价格','数量', '说明', '状态', '操作'],
				   	colModel:[
				   		{name:'ID',index:'ID', hidden:true},
				   		{name:'FOODNAME',index:'FOODNAME', align:'center'},
				   		{name:'PRICE', index:'PRICE', align:'center'},
				   		{name:'AMOUNT', index:'AMOUNT', align:'center'},
				   		{name:'DECLARE', index:'DECLARE', align:'center'},
				   		{name:'STATUS', index:'STATUS', editable: false, formatter:'select', editoptions:{value:"0:订单取消;1:正常;2:商家取消;3:用户取消"}, align:'center'},
				   		{name:'ctrl', index:'ctrl', align:'center', sortable:false}
				   	],
				   	width:850,
				   	height:230,
				   	rowNum:10,
				   	rowList:[10,20,30],
				   	pager: '#_detailBar',
				   	sortname: 'id',
				    viewrecords: true,
				    sortorder: "desc",
					multiselect: false,
					jsonReader: {
						repeatitems : false
					},
					rownumbers : true,
					caption: "订单详情列表",
					afterInsertRow : function(rowid, data) {
						$("#_detailGrid").jqGrid(
								'setCell', 
								rowid, 
								'ctrl', 
								'<span style="cursor:pointer;" onclick="_cancelDetail(' + data.ID + ',' + data.STATUS + ');">' + (data.STATUS == 1 ? '正常' : '取消') + '</span>'+ 
								'|<span style="cursor:pointer;" onclick="_delDetail(' + data.ID + ');">删除</span>', 
								{color:'green'}
						);
					}
				});
				$("#_detailGrid").jqGrid('navGrid','#_detailBar',{add : false, del : false, edit : false, refresh : true, search : false});
		});
			
		function _cancelDetail(id, status) {
			$.post("${base}/order_changeDetailStatus/${orderId}," + id + "," + status, 
					function(data) {
						if (data && data.success) {
							alert(data.msg);
							$("#_detailGrid").jqGrid('setGridParam',{url: '${base}/order_getDetailList/${orderId }'}).trigger("reloadGrid");
						} else {
							alert(data.msg);
						}
					}, 
			"json");
		}
		
		function _delDetail(id) {
			$.post("${base}/order_deleteOrderDetails/${orderId}," + id, 
					function(data) {
						if (data && data.success) {
							alert(data.msg);
							$("#_detailGrid").jqGrid('setGridParam',{url: '${base}/order_getDetailList/${orderId }'}).trigger("reloadGrid");
						} else {
							alert(data.msg);
						}
					}, 
			"json");
		}
			
		function _back() {
			window.location.href = "${base }/shop_shopManagerList";
		}
		</script>
	<body>
	<table cellpadding="0" cellspacing="0" border="0" width="99%" style="height:100%;">
		<tr><td style="height:10px; overflow:hidden;" colspan="2"></td></tr>
		<tr>
			<td width="*" valign="top" class="contList">
				<div id="_shopManagerDiv">
					<!-- 订单详情 -->
					<table id="_detailGrid"></table>
					<div id="_detailBar"></div>
				</div>
			</td>
	</table>
	</body>
</html>
